package com.sk.gzwater.view;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.sk.gzewop.R;
import com.sk.gzwater.adapter.MyExpandListviewAdapter;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ExpandableListView;
import android.widget.TextView;

public class ShujuShangbaoShenheWanchenglvDatalist extends Activity {
	private ExpandableListView data;
	private String[]shuichangNameStrings;
	private String [][]shuichangDataStrings;
	private ArrayList<HashMap<String, String>> datalist;
	private TextView time;
	private Intent intent;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.shujushangbaoshenhewanchenglv_datalist);
		intent = getIntent();
		initialize();
	}
	protected void initialize(){
		setData();		
		time = (TextView)findViewById(R.id.tv_shujushangbaoshenhewanchenglv_time);
		time.setText(intent.getExtras().getString("sttime")+"~"+intent.getExtras().getString("endtime"));
		data = (ExpandableListView)findViewById(R.id.shujushangbaoshenhewanchenglv_data);
		MyExpandListviewAdapter dataAdapter = new MyExpandListviewAdapter(ShujuShangbaoShenheWanchenglvDatalist.this);
		dataAdapter.setName(shuichangNameStrings);
		dataAdapter.setItem(shuichangDataStrings);
		data.setAdapter(dataAdapter);
		data.setGroupIndicator(null);				
	}
	protected void setData(){
		datalist = (ArrayList<HashMap<String,String>>)intent.getSerializableExtra("datalist");		
		shuichangNameStrings = new String[datalist.size()];
		shuichangDataStrings = new String[datalist.size()][datalist.get(0).size()-1];
		for (int i = 0; i < datalist.size(); i++) {
			shuichangNameStrings[i] = datalist.get(i).get("plantName");
			shuichangDataStrings[i][0] = datalist.get(i).get("HuaYanTBRare");
			shuichangDataStrings[i][1] = datalist.get(i).get("HuaYanSHRare");
			shuichangDataStrings[i][2] = datalist.get(i).get("ShengChanTBRare");
			shuichangDataStrings[i][3] = datalist.get(i).get("ShengChanSHRare");
		}
	}
}
